package org.lanqiao.music.web.config;

import org.lanqiao.music.web.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置资源的虚拟访问路径
        registry.addResourceHandler("/music/**","/images/**") //"/images/**"头像的虚拟路径
                .addResourceLocations("file:F:\\music\\","file:D:\\abc\\");//电脑的路径自己写一个
    }


    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/api/login","/api/captcha","/api/register","/api/upload","/images/**","/api/music/hotMusicAdd","/api/music/search","/api/comment/getAll","/api/comment/save");
    }
}
